import { getAreaObj, uploadType } from '@/utils/util'

export const formConfig = {
	inline: false,
	showBtn: true,
	labelPosition: 'top',
	labelWidth: '120px',
	column: [
		{
			label: '所属机构',
			prop: 'organizationId',
			propName: 'organizationName',
			type: 'remoteSelect',
			api: 'view_dpServiceOrgBase_page',
			filterKey: 'creditCode',
			filterLabel: 'organizationName',
			multiple: false,
			rules: [{ required: true, message: '请选择当前所属机构' }],
			span: 12,
			change: (item, form, value) => {
				if (!item.creditCode) {
					return
				}
				form.provinceId = item.provinceId
				form.provinceName = item.provinceName
				form.cityId = item.cityId
				form.cityName = item.cityName
				form.areaId = item.areaId
				form.areaName = item.areaName
				form.streetId = item.streetId
				form.streetName = item.streetName
				form.communityId = item.communityId
				form.communityName = item.communityName
			},
		},
		{
			label: '培训名称',
			prop: 'trainTitle',
			type: 'input',
			rules: [{ required: true, message: '请输入培训名称' }],
			span: 12,
		},
		{
			label: '培训时间',
			prop: 'trainTime',
			type: 'date',
			format: 'YYYY年MM月DD日',
			valueFormat: 'YYYY-MM-DD',
			rules: [{ required: true, message: '请选择培训时间' }],
			span: 12,
		},
		{
			label: '培训人',
			prop: 'staffName',
			// propName: 'staffName',
			// type: 'remoteSelect',
			type: 'input',
			// api: 'sys_user_querypage',
			// filterKey: 'userId',
			// filterLabel: 'realName',
			// multiple: false,
			// paramsObj: {
			// 	// roleName: '安全员',
			// 	classifyId: 4,
			// },
			span: 12,
		},
		{
			label: '参与方',
			prop: 'party',
			type: 'input',
			rules: [{ required: true, message: '请输入参与方' }],
			span: 12,
		},
		{
			label: '培训内容',
			prop: 'trainContent',
			type: 'textarea',
			maxlength: '500',
			showWordLimit: true,
			autosize: {
				minRows: 1,
			},
			span: 12,
		},
		{
			label: '培训图片',
			prop: 'trainPhoto',
			type: 'upload',
			listType: 'picture-card',
			labelPosition: 'top',
			showFileList: true,
			limit: 4,
			multiple: true,
			changeField: true,
			span: 24,
			rules: [{ required: true, message: '请上传培训图片' }],
		},
		{
			label: '签字照片',
			tip: '',
			prop: 'signaturePic',
			type: 'upload',
			labelPosition: 'top',
			showFileList: false,
			limit: 1,
			multiple: false,
			span: 24,
		},
	],
}


export const tableConfig = {
	stripe: true,
	border: true,
	columns: [
		{ label: '培训名称', prop: 'trainTitle' },
		{
			label: '培训内容',
			prop: 'trainContent',
		},
		{ label: '培训时间', prop: 'trainTime' },
		{ label: '培训人', prop: 'staffName' },
		{ label: '参与方', prop: 'party' },
		{
			label: '操作',
			prop: 'menu',
			width: 100,
			fixed: 'right',
		},
	],
}

export const api = {
	index: 'view_pbFireEducation_page',
}
export const baseConfig = {
	pageName: '消防安全教育培训记录',
	dictcodes: [],
	rowKey: 'id',
	addLabel: '新增',
	tipLabel: 'trainTitle',
	exportMqTopic: '/ning/export/',
	api,
	auth: {
		...api,
	},
	paramsObj: {
		source: 1,
	},
	menuBtn: [
		{
			icon: 'detail',
			label: '查看',
			type: 'primary',
			operate: 'detail',
			auth: api.index,
			text: true,
			show: true,
		},
	],
	dialogConfig: {
		width: '55%',
	},
	formConfig,
	tableConfig,
	detailConfig: formConfig,
	beforeOnLoadFormate: async (params) => {
		return new Promise((resolve, reject) => {
			const areaObj: any = getAreaObj(params.areas)
			resolve({
				...params,
				...areaObj,
				areas: undefined,
			})
		})
	},
}
